// 项目路径
var strPath = window.document.location.pathname;
var postPath = '/gdp';
var editTable = false;
var primaryKeys = {}; // 编辑服务关联主键
var sysFuncs = {}; // 系统格式化函数存储对象
var editField = {}; // 编辑是否为主键

// 表单验证状态
var formValid = true;
var formMessage = '';

var notyf = new Notyf();

// 列表单元格格式化
var formatterDfcode = function (value, row, index) {
    if (!value) {
        var ps = row.dfnameCn ? '（' + row.dfnameCn + ')' : '';
        value = row.dfname + ps;
        row.dfcode = value;
    }
    return value;
};
var formatterSwitch = function (value, row, index) {
    return (
        '<div class="switch switch-small tableSwitch" id="' +
        row['fieldguid'] +
        '"><input type="checkbox" data-on-text="YES" data-off-text="NO"/></div>'
    );
};
var formatterType = function (value, row, index) {
    var showType = '';
    switch (value) {
        case 0 :
            showType = '文本框';
            break;
        case 1 :
            showType = '时间框';
            break;
        case 2 :
            showType = '下拉框';
            break;
    }
    return '<span class="edit-cell" data-type="' + value + '">' + showType + '</span>';
};
var formatterEdit = function (value, row, index) {
    return '<span  class="edit-cell">' + (value || '') + '</span>';
};
var formatterInitData = function (value, row, index) {
    var sysFuncsObj = sysFuncs[value];
    return '<span  class="edit-cell">' + (sysFuncsObj ? sysFuncsObj.functitle + ' ' + row.highlight : value) + '</span>';
};

// 查询条件列表
var QUERY_FIELD_COLUMNS = [
    {
        title: '显示字段',
        field: 'dfnameCn',
        align: 'center',
        valign: 'middle',
        width: 300,
        formatter: formatterEdit
    },
    {
        title: '字段Code',
        field: 'dfname',
        align: 'center',
        valign: 'middle',
        width: 300
    },
    {
        title: '显示类型',
        field: 'showtype',
        align: 'center',
        valign: 'middle',
        width: 150,
        formatter: formatterType
    },
    {
        title: '初始化数据',
        field: 'initdata',
        align: 'center',
        valign: 'middle',
        formatter: formatterInitData
    }
];
// 显示列表字段
var TABLE_FIELD_COLUMNS = [
    {
        title: '字段Code',
        field: 'dfcode',
        align: 'center',
        width: 300,
        valign: 'middle',
        formatter: formatterDfcode
    },
    {
        title: '列宽',
        field: 'columnwidth',
        align: 'center',
        valign: 'middle',
        width: 150,
        formatter: formatterEdit
    },
    {
        title: '列位置',
        field: 'columnalign',
        align: 'center',
        valign: 'middle',
        width: 150,
        formatter: function (value, row, index) {
            var showType = '';
            switch (value) {
                case 'center' :
                    showType = '居中';
                    break;
                case 'right' :
                    showType = '居右';
                    break;
                case 'left' :
                    showType = '居左';
                    break;
            }
            return '<span class="edit-cell">' + showType + '</span>';
        }
    },
    {
        title: '是否显示',
        field: 'isshow',
        align: 'center',
        valign: 'middle',
        width: 150,
        formatter: formatterSwitch
    },
    {
        title: '格式化',
        field: 'columnformat',
        align: 'center',
        valign: 'middle',
        width: 150,
        formatter: formatterInitData
    }
];
// 编辑字段
var EDIT_FIELD_COLUMNS = [
    {
        title: '字段Code',
        field: 'dfcode',
        align: 'center',
        width: 300,
        valign: 'middle',
        formatter: formatterDfcode
    },
    {
        title: '是否显示列',
        field: 'isshow',
        align: 'center',
        valign: 'middle',
        width: 150,
        formatter: formatterSwitch
    },
    {
        title: '显示类型',
        field: 'showtype',
        align: 'center',
        valign: 'middle',
        width: 150,
        formatter: formatterType
    },
    {
        title: '初始化数据',
        field: 'initdata',
        align: 'center',
        valign: 'middle',
        formatter: formatterInitData
    },
    {
        title: '列表主键',
        field: 'requirekey',
        align: 'center',
        width: 150,
        valign: 'middle',
        formatter: function (value, row, index) {
            if (editField[row.dfname] === 1) {
                return '<span  class="edit-cell">' + (value ? primaryKeys[value] : '') + '</span>';
            }
            return '<span class="disable-cell"></span>';
        }
    }
];

$(function () {
    // 初始化页面数据
    initPageData();

    // 获取系统函数
    Service.getSysFunction();

    // 编辑启用选择绑定
    var theState = Utils.getQueryString('enable') === '1';
    Utils.bindSwitch('#editSwitch', theState, function () {
        var $switch = $('#editSwitch input');

        function isShow(state) {
            if (state) {
                $('.edit_row').show(200);
            } else {
                $('.edit_row').hide(200);
            }
        }

        isShow($switch.bootstrapSwitch('state'));
        $switch.on('switchChange.bootstrapSwitch', function (e, state) {
            isShow(state);
        });
    });

    // 绑定返回按钮事件
    $('#btn_back').on('click', function () {
        goBack();
    });

    // 绑定提交事件
    $('#btn_serverSave').on('click', function () {
        var data = {};
        $('#pageDetail')
            .serializeArray()
            .map(function (item) {
                data[item.name] = data[item.name] ? data[item.name] + ',' + item.value : item.value;
            });

        // 是否启用 编辑
        data['enable'] = $('#editSwitch input').bootstrapSwitch('state') ? 1 : 0;
        data['editfunc'] = data['editfunc'] ? data['editfunc'] : '';

        // 使用 pagecode 判断是增加还是修改
        var url = 'sysPageBaseInfo/insertPageBaseInfo';
        if (editTable) url = 'sysPageBaseInfo/updatePageBaseInfo';
        if (!Service.vaildForm(data)) return;

        Utils.$ajaxHttp(url, data, function (result) {
            if (result > 0) {
                editTable = true;
                var tableData = Service.getTableData();
                Utils.$ajaxHttp('sysPageDetailsInfo/insertPageDetailsinfoBatch', {
                    pageCode: data['pagecode'],
                    pageDetailsinfos: JSON.stringify(tableData)
                }, function (result) {
                    result > 0 ? notyf.confirm("数据保存成功") : notyf.alert("数据保存失败");
                }, 'POST');
            }
        }, 'POST');

    });
});

/**
 * 初始化页面数据
 */
function initPageData() {
    // 获取 pagecode
    var pagecode = Utils.getQueryString('pagecode');
    if (pagecode) {
        $('#hid_pagecode').val(pagecode);
        editTable = true;
    } else {
        $('#hid_pagecode').val('pageConfig_' + Utils.randomWord(false, 4, 4));
        editTable = false;
    }

    // 获取 项目工程
    Service.getProjectSelect();
    // 绑定 项目工程
    $('#pcode').on('change', function () {
        Service.getServiceData();
        Service.getTableEditServerData();
    });

    // 绑定 服务类型 事件
    $('#searchserviceid').on('change', function () {
        var $hidServiceType = $('#hid_servicetype');
        $hidServiceType.val($(this).find('option:selected').data('type'));
        var paramsData = {
            serviceId: $('#searchserviceid').val(),
            pageCode: $('#hid_pagecode').val()
        };
        // 绑定查询列表数据
        Utils.$ajaxHttp('sysPageDetailsInfo/getAllQueryFieldByServiceId', paramsData, function (result) {
            Utils.bindTableColumns('tb_queryFieldList', QUERY_FIELD_COLUMNS, result.data);
        });
        var showFiledUrl = 'sysPageDetailsInfo/' + ($hidServiceType.val() === 'singleTableServer' ? 'getAllShowFieldByServiceId' : 'getAllShowFieldExecSQLByServiceId');
        //  绑定显示列表数据
        Utils.$ajaxHttp(showFiledUrl, paramsData, function (result) {
            $.each(result.data, function (index, data) {
                primaryKeys[data.dfname] = data.dfname + (data.dfnameCn ? '（' + data.dfnameCn + ')' : '');
            });
            Utils.bindTableColumns('tb_tableFieldList', TABLE_FIELD_COLUMNS, result.data);
        });
    });

    // 绑定 编辑服务 事件
    $('#editserviceid').on('change', function () {
        var paramsData = {
            serviceId: $('#editserviceid').val(),
            pageCode: $('#hid_pagecode').val()
        };

        /**
         * 获取编辑服务是否是主键
         */
        Utils.$ajaxHttp('tableEdit/getAllBaseEditByServiceId', paramsData, function (result) {
            $.each(result, function (index, data) {
                editField[data['dfname']] = data['iscondition'];
            });
            //  绑定编辑列表数据
            Utils.$ajaxHttp('sysPageDetailsInfo/getEditExecSQLByServiceId', paramsData, function (result) {
                Utils.bindTableColumns('tb_editFieldList', EDIT_FIELD_COLUMNS, result.data);
            });
        });
    });

    // 获取页面基本信息
    if (pagecode) {
        Utils.$ajaxHttp('sysPageBaseInfo/getPageBaseInfoByPageCode', {pagecode: pagecode}, function (result) {
            if (result.success && result.data) {
                $('#pagename').val(result.data.pagename);
                result.data.editfunc.split(',').map(function (data) {
                    if (data) {
                        $(':checkbox[name="editfunc"]')
                            .eq(data)
                            .prop('checked', true);
                    }
                });
            }
        });
    }

    // 绑定查询参数列表
    Utils.bindTableColumns('tb_queryFieldList', QUERY_FIELD_COLUMNS, []);
    // 绑定表格列表
    Utils.bindTableColumns('tb_tableFieldList', TABLE_FIELD_COLUMNS, []);
    // 绑定编辑列表
    Utils.bindTableColumns('tb_editFieldList', EDIT_FIELD_COLUMNS, []);
}

var Service = {
    getProjectSelect: function () {
        var projectid = Utils.getQueryString('projectid');
        $('#pcode').html('');
        // sysprjService/getProjectList
        Utils.$ajaxHttp('sysProject/getProjectToUser', '', function (result) {
            var $pcode = $('#pcode');
            if (result.success && result.data != null && result.data.length > 0) {
                var str = "<option value=''>请选择</option>";
                for (var i = 0; i < result.data.length; i++) {
                    str += "<option value='" + (result.data[i].id || result.data[i].pcode) + "'>" + (result.data[i].name || result.data[i].pname) + "</option>";
                }
                $pcode.append(str);
            }
            // 设置选中值
            $pcode.find('option[value="' + projectid + '"]').attr('selected', true);
            if (projectid) $pcode.trigger('change');
        }, 'POST');
    },
    getServiceData: function () {
        var searchserviceid = Utils.getQueryString('searchserviceid');
        Utils.$ajaxHttp('sysPageDetailsInfo/getServiceBytype', {
            pcode: $('#pcode').val(),
            servertype: ['singleTableServer', 'executeSqlServer']
        }, function (result) {
            var $searchService = $('#searchserviceid');
            if (result.success) {
                var options = '<option value="">请选择</option>';
                for (var i = 0; i < result.data.length; i++) {
                    options += '<option value="' + result.data[i].servicecode + '" data-type="' + result.data[i].servicetype + '">' + result.data[i].servicename + '</option>';
                }
                $searchService.html(options);
                // 设置选中值
                $searchService.find('option[value="' + searchserviceid + '"]').attr('selected', true);
                $searchService.trigger('change');
            }
        }, 'POST');
    },
    getTableEditServerData: function () {
        var editserviceid = Utils.getQueryString('editserviceid');
        Utils.$ajaxHttp('sysPageDetailsInfo/getServiceBytype', {
            pcode: $('#pcode').val(),
            servertype: ['tableEditServer']
        }, function (result) {
            var $editserviceid = $('#editserviceid');
            if (result.success) {
                var options = '<option value="">请选择</option>';
                for (var i = 0; i < result.data.length; i++) {
                    options += '<option value="' + result.data[i].servicecode + '" data-type="' + result.data[i].servicetype + '">' + result.data[i].servicename + '</option>';
                }
                $editserviceid.html(options);
                // 设置选中值
                $editserviceid.find('option[value="' + editserviceid + '"]').attr('selected', true);
                $editserviceid.trigger('change')
            }
        }, 'POST');
    },
    getSysFunction: function () {
        Utils.$ajaxHttp('sysfunc/getSysFunc', '', function (result) {
            if (result.success) {
                result.data.map(function (data) {
                    sysFuncs[data.guid] = data;
                });
            }
        });
    },
    getTableData: function () {
        var data = [];
        var queryFieldRow = $('#tb_queryFieldList').bootstrapTable('getData');
        for (var i = 0; i < queryFieldRow.length; i++) {
            queryFieldRow[i]['pagefieldtype'] = 1;
            queryFieldRow[i]['isshow'] = 1;
        }

        var tableFieldRow = $('#tb_tableFieldList').bootstrapTable('getData');
        for (var j = 0; j < tableFieldRow.length; j++) {
            tableFieldRow[j]['pagefieldtype'] = 2;
            tableFieldRow[j]['showtype'] = -1;
            tableFieldRow[j]['inittype'] = -1;
            var isshow = $('#' + tableFieldRow[j]['fieldguid'] + ' input').bootstrapSwitch('state') ? 1 : 0;
            tableFieldRow[j]['isshow'] = isshow;
        }

        var editFieldRow = [];
        if ($('#editSwitch input').bootstrapSwitch('state')) {
            editFieldRow = $('#tb_editFieldList').bootstrapTable('getData');
            for (var k = 0; k < editFieldRow.length; k++) {
                editFieldRow[k]['pagefieldtype'] = 3;
                var isshow = $('#' + editFieldRow[k]['fieldguid'] + ' input').bootstrapSwitch('state') ? 1 : 0;
                editFieldRow[k]['isshow'] = isshow;
            }
        }

        Array.prototype.push.apply(data, queryFieldRow);
        Array.prototype.push.apply(data, tableFieldRow);
        Array.prototype.push.apply(data, editFieldRow);

        return data;
    },
    vaildForm: function (data) {
        var $valide_dtMessage = $('#valide_dtMessage');
        if (!data['pagename']) {
            $valide_dtMessage.text('请输入页面名称');
            return false;
        }
        if (!data['pcode']) {
            $valide_dtMessage.text('请选择项目工程');
            return false;
        }
        if (!data['searchserviceid']) {
            $valide_dtMessage.text('请选择查询服务');
            return false;
        }
        if (data['enable'] === 1 && !data['editserviceid']) {
            $valide_dtMessage.text('请选择编辑服务');
            return false;
        }

        // 验证查询列表
        var queryFieldRow = $('#tb_queryFieldList').bootstrapTable('getData');
        for (var i = 0; i < queryFieldRow.length; i++) {
            if (queryFieldRow[i]['showtype'] === 2 && queryFieldRow[i]['initdata'] === '') {
                $valide_dtMessage.text('查询的条件，下拉框类型，必须设置初始化数据');
                return false;
            }
        }

        // 验证编辑列表
        var editFieldRow = [];
        if ($('#editSwitch input').bootstrapSwitch('state')) {
            editFieldRow = $('#tb_editFieldList').bootstrapTable('getData');
            for (var k = 0; k < editFieldRow.length; k++) {
                if (editFieldRow[k]['showtype'] === 2 && editFieldRow[k]['initdata'] === '') {
                    $valide_dtMessage.text('编辑列名，下拉框类型，必须设置初始化数据');
                    return false;
                }

                if (editField[editFieldRow[k].dfname] === 1 && !editFieldRow[k].requirekey) {
                    $valide_dtMessage.text('请选择编辑列名 ' + editFieldRow[k].dfname + ' 的列表主键');
                    return false;
                }
            }
        }

        if (!formValid) {
            $valide_dtMessage.text(formMessage);
            return formValid;
        }

        $valide_dtMessage.text('');
        return true;
    }
};

/**
 * 工具方法
 * @type {{$ajaxHttp: Utils.$ajaxHttp, getQueryStringSeachTxt: Utils.getQueryStringSeachTxt, getQueryString: Utils.getQueryString, randomWord: (function(*=, *, *): (string|string)), bindSwitch: Utils.bindSwitch}}
 */
var Utils = {
    randomWord: function (randomFlag, min, max) {
        var str = '',
            range = min,
            arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];

        // 随机产生
        if (randomFlag) {
            range = Math.round(Math.random() * (max - min)) + min;
        }
        for (var i = 0; i < range; i++) {
            pos = Math.round(Math.random() * (arr.length - 1));
            str += arr[pos];
        }
        return str;
    },
    $ajaxHttp: function (url, data, func, method) {
        method = method || 'GET';
        $.ajax({
            url: postPath + '/system/' + url,
            method: method,
            data: data,
            dataType: 'json'
        }).done(function (result) {
            func && func(result);
        });
    },
    getQueryString: function (name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    },
    getQueryStringSearchTxt: function (name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return r[2];
        return null;
    },
    bindSwitch: function (el, state, func) {
        $(el + ' input').bootstrapSwitch('state', state);
        $(el + ' input').bootstrapSwitch({
            onText: '开启',
            offText: '关闭'
        });
        func && func();
    },
    bindTableColumns: function (el, columns, columnData) {
        $('#' + el)
            .bootstrapTable('destroy')
            .bootstrapTable({
                data: columnData,
                columns: columns,
                undefinedText: '-',
                striped: true, // 是否显示行间隔色
                cache: false, // 是否使用缓存
                uniqueId: 'guid', // 每一行的唯一标识
                onPostBody: function () {
                    Utils.bindSwitch('#' + el + ' .tableSwitch', true);
                    $.each(columnData, function (index, data) {
                        $('#' + data['fieldguid'] + ' input').bootstrapSwitch('state', data['isshow'] === 1);
                    });
                    var $disableCell = $('#' + el).find('span.disable-cell');
                    $disableCell.height($disableCell.parent().outerHeight());
                },
                onClickCell: function (field, value, row, $element) {
                    var editField = ['dfnameCn', 'showtype', 'columnwidth', 'initdata', 'columnalign', 'columnformat', 'requirekey'];
                    if (editField.indexOf(field) !== -1 && $element.find('.edit-cell').length > 0) {
                        var $component = Component.init(field, $element);
                        $element.html($component);
                        $component.val(value).focus();

                        // 添加函数参数配置
                        if (field === 'initdata' && $component.is('select')) {
                            $component.css({'display': 'inline-block'});
                            var initValue = row.highlight;
                            var defaultData = '';
                            if (!$component.next().is('input')) {
                                $component.after('<input class="form-control func-params" id="funcParams" style="" value="' + initValue + '">');
                            }
                            // 函数参数
                            var $funcParams = $('#funcParams');

                            // 获取函数参数
                            $component.on('change', function () {
                                defaultFuncValue($component.val());
                                $funcParams.val(defaultData);
                            });

                            // 获取函数参数
                            $funcParams.on('blur', function () {
                                var paramsValue = $.trim($funcParams.val());
                                var errorMsg = '请输入函数参数';
                                if (paramsValue === defaultData) {
                                    notyf.alert(errorMsg);
                                    Component.setFormValid(false, errorMsg);
                                } else {
                                    row.highlight = paramsValue;
                                    Component.setFormValid(true, '');
                                    onBlurRowData();
                                }
                            });
                        }

                        $component.on('blur', function () {
                            if (field === 'initdata' && $component.is('select')) {
                                return $('#funcParams').trigger('blur');
                            }
                            onBlurRowData();
                        });

                        // 获取默认参数
                        var defaultFuncValue = function (guid) {
                            var func = sysFuncs[guid];
                            var funcScript = func.funcscript;
                            var params = funcScript.substring(funcScript.indexOf('(') + 1, funcScript.indexOf(')'));
                            defaultData = func.funcname + '(' + params + ')';
                        };
                        // 更新行
                        var onBlurRowData = function () {
                            var result = Component.valid(field, $component, $element);
                            if (!result.isValid) return;
                            $('#' + el).bootstrapTable('updateCell', {
                                index: $element.parent().data('index'),
                                field: field,
                                value: result.value
                            });
                        };
                    }
                }
            });
    }
};

var Component = {
    init: function (field, $parent) {
        var newHtml = '<input type="text" class="form-control"/>';
        switch (field) {
            case 'showtype':
                newHtml = '<select class="form-control"><option value="0">文本框</option><option value="1">时间框</option><option value="2">下拉框</option></select>';
                break;
            case 'columnalign':
                newHtml = '<select class="form-control"><option value="left">居左</option><option value="center">居中</option><option value="right">居右</option></select>';
                break;
            case 'columnwidth':
                newHtml = '<input type="number" class="form-control" />';
                break;
            case 'columnformat':
                newHtml = Component.selectList(sysFuncs);
                break;
            case 'requirekey':
                newHtml = Component.selectList(primaryKeys);
                break;
            case 'initdata':
                var type = $parent.prev().find('span').data('type');
                newHtml = type === 1 ? Component.selectList(sysFuncs) : newHtml;
                break;
        }
        return $(newHtml);
    },
    valid: function (field, $component, $parent) {
        var isValid = true, value = $component.val();
        switch (field) {
            case 'showtype':
                value = parseInt($component.val());
                // 清空初始化数据
                $parent.parents('table').bootstrapTable('updateCell', {
                    index: $parent.parent().data('index'),
                    field: 'initdata',
                    value: ''
                });
                break;
            case 'initdata':
                var type = $parent.prev().find('span').data('type');
                if (type === 2 && $.trim(value) !== '') {
                    var reg = /^SELECT/ig;
                    if (reg.test($.trim(value))) {
                        // 验证 SQL 格式是否正确
                        isValid = Component.validSQL($.trim(value));
                    } else {
                        // 验证  JSON 格式是否正确
                        isValid = Component.validJSON($.trim(value));
                    }
                }
                break;
        }
        return {isValid: isValid, value: value};
    },
    selectList: function (data) {
        var newHtml = '<select class="form-control"><option value="">请选择</option>';
        for (var key in data) {
            if (typeof data[key] === 'object') {
                newHtml += '<option value="' + key + '">' + data[key].functitle + '</option>';
            } else {
                newHtml += '<option value="' + key + '">' + data[key] + '</option>';
            }
        }
        return newHtml + '</select>';
    },
    validSQL: function (value) {
        var sqlReg = /^select \w+ as text, \w+ as value from \w+/g; // SQL 正则表达式
        var errmsg = 'SQL 格式错误，正确格式为: select xx as text, xx as value from xx';
        var state = true;
        if (!sqlReg.test(value)) {
            notyf.alert(errmsg);
            return Component.setFormValid(false, errmsg);
        } else {
            // 尝试后台执行 sql
            $.ajax({
                type: 'POST',
                url: postPath + '/system/sysPageDetailsInfo/executeSQLByServiceId',
                async: false,
                data: {
                    serviceId: $('#searchserviceid').val(),
                    type: $('#hid_servicetype').val(),
                    sql: value
                },
                success: function (res) {
                    state = res.success;
                    if (!res.success) {
                        errmsg = 'SQL 语句执行错误，请检查';
                        notyf.alert(errmsg);
                    } else {
                        errmsg = '';
                    }
                }
            });
        }
        return Component.setFormValid(state, errmsg);
    },
    validJSON: function (value) {
        var jsonReg = /^\[({ "text": "[a-zA-Z0-9\u4e00-\u9fa5]+", "value": "[a-zA-Z0-9\u4e00-\u9fa5]+" },)*({ "text": "[a-zA-Z0-9\u4e00-\u9fa5]+", "value": "[a-zA-Z0-9\u4e00-\u9fa5]+" })]$/g;
        var errmsg = 'JSON 格式错误，正确格式为:  [{ "text": "xx", "value": "xx" }]';
        if (!jsonReg.test(value)) {
            notyf.alert(errmsg);
            return Component.setFormValid(false, errmsg);
        }
        return Component.setFormValid(true, '');
    },
    setFormValid: function (state, msg) {
        formMessage = msg;
        formValid = state;
        $('#valide_dtMessage').text(formMessage);
        return state;
    }
};

/**
 * 返回按钮事件
 */
function goBack() {
    var projectId = Utils.getQueryString('projectid');
    var serverType = Utils.getQueryString('servertype');
    var searchTxt = Utils.getQueryStringSearchTxt('seachTxt');
    window.location.href =
        postPath + '/pageBaseInfo/index?order=asc&pageNo=1&pageSize=10&seachTxt=' +
        searchTxt +
        '&pcode=' +
        projectId +
        '&servertype=' +
        serverType;
}

